
from django.db.models import BooleanField,IntegerField,ForeignKey,DO_NOTHING,TextField,DateTimeField,PROTECT
from apps.vadmin.op_drf.models import CoreModel

"""
资产组件只能借出给资产,且需要归还
"""
class ComponentRecords(CoreModel):
    component = ForeignKey(to="assets.Components",null=True,db_constraint=False,on_delete=PROTECT,verbose_name="借出资产组件Id")
    assigned_asset = ForeignKey(to="assets.Assets",null=True,db_constraint=False,on_delete=PROTECT,verbose_name="借用资产") 
    checkout_qty = IntegerField(null=True,verbose_name="借出数量")
    checkin_qty = IntegerField(null=True,default=0,verbose_name="归还数量")
    checkin_datetime = DateTimeField(null=True,verbose_name="归还日期")
    is_checkin= BooleanField(null=True,default=0,verbose_name="是否归还")
    checkout_notes = TextField(null=True,verbose_name="借出备注")
    checkin_notes = TextField(null=True,verbose_name="归还备注")


    class Meta:
        verbose_name = '资产组件借用归还记录表'
        verbose_name_plural = verbose_name
